IWCGJQAutoComplete.JQAutoCompleteOptions.MinLength:= 2;
IWCGJQAutoComplete.JQAutoCompleteOptions.Delay:= 400;
IWCGJQAutoComplete.OnGetAutoCompleteData:= AutoCompleteGetAutoCompleteData;

procedure TIWAutoCompleteFrame.AutoCompleteGetAutoCompleteData(Sender: TObject; const ATerm: string);
var
  JSon: ISuperObject;
  DescField: TField;
begin
  nxQuery.Close;
  nxQuery.SQL.Clear;
  nxQuery.SQL.Add('select * from products');
  nxQuery.SQL.Add('where ProductDescription like ''%'+ATerm+'%''');
  nxQuery.Open;

  DescField:= nxQuery.FieldByName('ProductDescription');

  JSon:= TSuperObject.Create(stArray);
  while not nxQuery.Eof do
  begin
    JSon.AsArray.Add(TSuperObject.Create(DescField.AsString));
    nxQuery.Next;
  end;

  WebApplication.Response.ContentType:= 'application/json';
  {$IFDEF IW12}
  WebApplication.Response.WriteString(JSon.AsJSon);
  {$ELSE}
  WebApplication.Response.Content:= JSon.AsJSon;
  {$ENDIF}
end;

